home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: Michael Smith <msmith@mpx.com.au>
- Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
- Subject: Re: C coding problem
- Date: 24 Mar 1996 11:47:42 -0600
- Organization: Emmenjay Consulting
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4j41ru$nq4@solutions.solon.com>
- References: <4ianbf$h86@solutions.solon.com> <4iemcl$a05@solutions.solon.com> <4io1io$no4@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Konrad Schwarz wrote:
- >
- > I recently wrote a loop that went like this:
- >
- > while (p < end_p)
- > ++*p++;
- >
-
- This is largely a matter of taste, but personally I don't like that
- construct. A programmer less skilled than you might easily misunderstand
- that and introduce an error. I would prefer:
-
- for ( ; p<end_p; p++)
- ++(*p);
-
- This is likely to run just as fast (particularly with an optimizing
- compiler) but there is much less chance of a future maintenance
- programmer misunderstanding it. The brackets around "*p" are, of course,
- redundant, but (in my opinion) add to the clarity.
-
- --
- #####################################################################
- Michael Smith msmith@mpx.com.au
- Emmenjay Consulting http://www.hutch.com.au/~emmenjay
- #####################################################################
-